import java.util.LinkedList;
import java.util.Scanner;

/**
 * Created by JiaJia on 2019/4/11 0011.
 */
public class WeiZhong01 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (sc.hasNext()){
            int n=sc.nextInt();
            int m=sc.nextInt();
            System.out.println(lastChild(n,m));
        }
        sc.close();
    }

    private static String lastChild(int n,int m){
        LinkedList<Integer> list=new LinkedList<>();
        StringBuilder sb=new StringBuilder();
        for (int i = 1; i <=n ; i++) {
            list.add(i);
        }
        int a=0;
        while (list.size()>1){
            a=(a+m-1)%list.size();
            sb.append(list.get(a)).append(" ");
            list.remove(a);
        }
        sb.append("\n");
        if (list.size()==1){
            sb.append(list.get(0));
        }

        return sb.toString();

    }
}